import { request } from '@/utils';

export function getWeixinPreData<T = any>() {
  return request<T>({
    url: '/sys/wxlogin/data',
    method: 'get'
  });
}

export function getWeixinLoginToken<T = any>({
  appId,
  appSecret,
  code
}: {
  appId: string;
  appSecret: string;
  code: string;
}) {
  return request<T>({
    url: '/sys/wxlogin/access_token',
    method: 'get',
    params: { appId, appSecret, code }
  });
}

export function getWeixinLoginUserInfo<T = any>({
  access_token,
  openid
}: {
  access_token: string;
  openid: string;
}) {
  return request<T>({
    url: '/sys/wxlogin/userinfo',
    method: 'get',
    params: { access_token, openid }
  });
}
